package com.ahwei;

import com.ahwei.context.AppContext;
import com.ahwei.dao.video.VideoDao;
import com.ahwei.pojo.Video;
import com.ahwei.service.CollectService;
import com.ahwei.service.UserService;
import com.ahwei.service.VideoService;
import com.ahwei.service.impl.CollectServiceImpl;
import com.ahwei.service.impl.UserServiceImpl;
import com.ahwei.service.impl.VideoServiceImpl;
import com.ahwei.util.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author：ahwei163@qq.com
 *
 * @date: 202*-03-14 21:14:58
 * @description: 这是一个Java文件！
 */
public class AppTest {

    @Test
    public void test(){
        UserService userService = new UserServiceImpl();
        VideoService videoService = new VideoServiceImpl();
        CollectService collectService = new CollectServiceImpl();

        /*PageResult<User> user = userService.findAllUser("", "", "", 1);
        System.out.println("user = " + user);*/
       /* PageResult<Video> all = videoService.findAll("", "asc", "browseCount", 1);
        all.getData().forEach(System.out::println);*/
        SqlSession sqlSession = MyBatisUtils.getSqlSession();
        VideoDao videoDao = sqlSession.getMapper(VideoDao.class);
        Map<String,Object> map = new HashMap<>();
        map.put("keyword","");
        map.put("column","browseCount");
        map.put("sort","asc");
        map.put("getData",0);
        map.put("pageCount",AppContext.PAGE_COUNT);

        List<Video> videoList = videoDao.findAll(map);
        videoList.forEach(System.out::println);
    /*    UserDetail userDetail = new UserDetail(0L,"qwer","保密",new Date(),"未知","img/user.jpg");
        User user = new User(0L,"qwer","123", AppContext.ROLE_STUDENT,userDetail);
        Result result = userService.userRegister(user);
        System.out.println(result.getMsg());
        Result qwer = userService.UserLogin("qwer", "123");
        System.out.println(qwer);*/
       /* PageAble<Video> all = videoService.findAll(null, null);
        for (Video o : all.getData()) {
            System.out.println(o);
        }*/
  /*      List<Video> vid = videoService.findAll(null,null).getData();
        System.out.println("vid = " + vid);
        List<Video> vid1 = videoService.findColumnOrderBy("browseCount");
        System.out.println("vid = " + vid1);
        List<Video> vid2 = videoService.findColumnOrderBy("downloadCount");
        System.out.println("vid = " + vid2);
        List<Video> vid3 = videoService.findByType(1);
        System.out.println("vid = " + vid3);*/
       // System.out.println(videoService.findByType(2));
       /* List<Video> broseCount = videoService.findColumnOrderBy("browseCount");
        broseCount.forEach(System.out::println);*/
        /*int i = collectService.addCollect(new Collect(1,4,new Date(),null));
        //int i = collectService.deleteCollect(1);

        System.out.println("i = " + i);*/
    }
}
